<template>
	<view class="contain">
		<uni-forms ref="form" v-model="formdata" style="margin-top: 30px;">
			<uni-forms-item label="旧密码" name="">
				<uni-easyinput type="password" v-model="formdata.oldPassword" placeholder="请输入旧密码"></uni-easyinput>
			</uni-forms-item>
			<uni-forms-item label="新密码" name="">
				<uni-easyinput type="password" v-model="formdata.newPassword" placeholder="请输入新密码"></uni-easyinput>
			</uni-forms-item>
			
		</uni-forms>
		<button @click="updatePwd" style="background-color: cornflowerblue;">保存</button>
	</view>
</template>

<script>
	import * as request from '@/unitl.js'
	export default {
		data() {
			return {
				formdata:{
					newPassword:'1234567',
					oldPassword:'123456'
				}
				
			}
		},
		methods: {
			async updatePwd(){
				const res=await request.default.updatapwd(this.formdata)
				console.log(res)
				if(res.data.code==200){
					uni.showToast({
						icon:"success",
						title:res.data.msg,
						// complete:()=> {
							
						// title:res.msg,
					}),
					
					setTimeout(()=>{
						uni.navigateTo({
								url:"/pages/login/login"
							})
					},1500)
					
					
				}else{
					uni.showToast({
						icon:'error',
						title:res.data.msg
					})
				}
			}
			
		}
	}
</script>

<style>

</style>
